<template>
	<xn-form-container title="详情" :width="1000" :visible="visible" :destroy-on-close="true" @close="onClose">
		<a-descriptions :column="2" bordered>
			<a-descriptions-item label="标题">{{ formData.title }}</a-descriptions-item>
			<a-descriptions-item label="类型">
				<a-tag :bordered="false" color="success" v-if="formData.type === '1'">
					通知
				</a-tag>
				<a-tag :bordered="false" color="processing" v-else-if="formData.type === '2'">
					公告
				</a-tag>
			</a-descriptions-item>
			<a-descriptions-item label="创建时间"><span>{{ formData.createTime }}</span></a-descriptions-item>
			<a-descriptions-item label="修改人"><span>{{ formData.updateUserName }}</span></a-descriptions-item>
			<a-descriptions-item label="内容"><div v-html="formData.content"></div></a-descriptions-item>
		</a-descriptions>
		<template #footer>
			<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
		</template>
	</xn-form-container>
</template>

<script setup name="bizNoticeDetail">
	import { message } from 'ant-design-vue'
	import noticeInfoApi from "@/api/biz/notice/noticeInfoApi";
	// 抽屉状态
	const visible = ref(false)
	const emit = defineEmits({ successful: null })
	// 表单数据
	const formData = ref({})
	const submitLoading = ref(false)
	// 打开抽屉
	const onOpen = (record) => {
		visible.value = true
		if (record) {
			let param = {
				id: record.id
			}
			noticeInfoApi.noticeInfoDetail(param).then((data) => {
				formData.value = Object.assign({}, data)
			})
		} else {
			message.warning('未查到该信息')
		}
	}
	// 关闭抽屉
	const onClose = () => {
		formData.value = {}
		visible.value = false
	}
	// 抛出函数
	defineExpose({
		onOpen
	})
</script>
